package com.example.module_car.vm

import androidx.lifecycle.MutableLiveData
import com.yuwei.base.BaseViewModel
import com.yuwei.http.ApiService
import com.yuwei.http.entity.*
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject
@HiltViewModel
class CarViewModel @Inject constructor(
    val apiService: ApiService
):BaseViewModel() {
    val getCarPaymentsSuccess by lazy { MutableLiveData<CarPaymentsEntity>() }
    fun getCarPayments(){
        executeNetwork({
            apiService.getCarPayments()
        },getCarPaymentsSuccess::postValue)
    }
    //省份简码
    val getCarProvincesSuccess by lazy { MutableLiveData<ProvincesEntity>() }
    fun getProvinces(){
        executeNetwork({
            apiService.getProvinces()
        },getCarProvincesSuccess::postValue)
    }
    //添加车辆
    val getAddCarSuccess by lazy { MutableLiveData<VehiclesEntity>() }
    fun getAddCar(vehiclesBody: VehiclesBody){
        executeNetwork({
            apiService.getVehicles(vehiclesBody)
        },getAddCarSuccess::postValue)
    }
    //删除车辆
    val getDeleteCarSuccess by lazy { MutableLiveData<String>() }
    fun deleteCar(id:Int){
        executeNetwork({
            apiService.getDeleteCar(id)
        },getDeleteCarSuccess::postValue)
    }
    //缴费
    val getAddPaymentsSuccess by lazy { MutableLiveData<AddPaymentsEntity>() }
    fun getAddPayments(addPaymentsBody: AddPaymentsBody){
        executeNetwork({
            apiService.getAddPayments(addPaymentsBody)
        },getAddPaymentsSuccess::postValue)
    }
}